import { piniaStore } from '.'

/**
 * request api loading variable store
 */
export const useLoadingStore = defineStore('apiloading', {
  state: () => {
    return {
      loading: false
    }
  },
  actions: {
    showLoading() {
      if(!this.loading) {
        uni.showLoading()
        this.loading = true
      }
    },
    hideLoading() {
      uni.hideLoading()
      this.loading = false
    }
  },
  persist: true // 配置持久化
})

export function useOutsideLoadingStore() {
  return useLoadingStore(piniaStore)
}
